package com.betterjr.modules.risk.api.service;

import java.util.Map;

import org.springframework.stereotype.Service;

import com.alibaba.dubbo.config.annotation.Reference;
import com.betterjr.common.utils.Collections3;
import com.betterjr.common.web.AbstarctRemoteApiInvoke;
import com.betterjr.common.web.AjaxRemoteApiParam;
import com.betterjr.modules.document.ICustFileService;

@Service
public class RemoteApiQueryFileItemInvokeService extends AbstarctRemoteApiInvoke {

    private String apiCode = "RAI00009";

    @Reference(interfaceClass = ICustFileService.class)
    private ICustFileService fileService;

    @Override
    public String saveOrFindInvoke(AjaxRemoteApiParam param) {

        return fileService.webQueryFilesByBatchOrId(findProperties(param.getParamMap(), "fileId", Long.class, 0L),
                findProperties(param.getParamMap(), "batchNo", Long.class, 0L));
    }

    @Override
    public boolean supportInvoke(String anApiCode) {

        return apiCode.equals(anApiCode);
    }

    @Override
    public boolean checkParam(Map<String, Object> anParamMap) {

        boolean flag = true;

        if (flag && Collections3.isEmpty(anParamMap)) flag = false;

        if (flag && !anParamMap.containsKey("fileId") && !anParamMap.containsKey("batchNo")) flag = false;

        return flag;
    }

}
